/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package th.stripes.action;

import com.google.inject.Inject;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;
import th.manager.PoskodManager;
import th.stripes.BaseActionBean;

/**
 *
 * @author fikri
 */
@UrlBinding("/poskod/{kodNegeri}")
public class PoskodActionBean extends BaseActionBean{
    
    private String kodNegeri;
    
    @Inject
    private PoskodManager poskodManager;    

    public String getKodNegeri() {
        return kodNegeri;
    }

    public void setKodNegeri(String kodNegeri) {
        this.kodNegeri = kodNegeri;
    }    
    
    public Resolution viewPoskod() {    
        String name_startsWith = getContext().getRequest().getParameter("name_startsWith");        
        return new StreamingResolution("text/plain", poskodManager.getPoskodAjaxAutoComplete(kodNegeri,name_startsWith));
    }
    
    public Resolution viewPoskodAndDesc() {    
        String name_startsWith = getContext().getRequest().getParameter("name_startsWith");        
        return new StreamingResolution("text/plain", poskodManager.getPoskodAndDescAjaxAutoComplete(kodNegeri,name_startsWith));
    } 
    
    //added in 17/6/2013
    public Resolution viewPoskodOnly() {           
        return new StreamingResolution("text/plain", poskodManager.getPoskodAjax(kodNegeri));
    }
}
